package com.cloud.lawcase.api.web;

import com.cloud.lawcase.api.entity.TcDicLaw;
import com.cloud.lawcase.api.entity.TcDicLawItem;
import com.cloud.lawcase.api.entity.TcLawClDetail;
import com.cloud.lawcase.api.entity.TcLawRelCauseExcuteType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.lawcase.api.bean.LawCauseInterfaceSearchCriteria;
import com.cloud.lawcase.api.bean.LawCauseItem;
import com.cloud.lawcase.api.constant.LawCaseConstant;
import com.cloud.lawcase.api.service.LawCauseInterfaceService;
import com.cloud.lawcase.interfaces.FeignClientSystem;
import com.github.pagehelper.PageInfo;

import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;
@ApiIgnore
@RestController
@RequestMapping("/lawcase/interface")
public class LawCauseInterfaceController {

	@Autowired
	private LawCauseInterfaceService lawCauseInterfaceService;

	@Autowired
	private FeignClientSystem feignClientSystem;

	@RequestMapping("/causesearch")
	public PageInfo<LawCauseItem> searhCausePageInfo(@RequestBody LawCauseInterfaceSearchCriteria criteria) {
		criteria.setAppKey(feignClientSystem.getConfigValueByKey(LawCaseConstant.LAWCAUSE_APP_KEY));
		return lawCauseInterfaceService.searhCausePageInfo(criteria);
	}

	/**
	 * 法律概况
	 *
	 * @return
	 */
	@GetMapping("infogeneral")
	public Map<String, Object> getInfoGeneral() {
		return lawCauseInterfaceService.getInfoGeneral();
	}

	/**
	 * 执法依据
	 *
	 * @return
	 */
	@GetMapping("statcauseexcutetype")
	public List<Map<String, Object>> statCauseExcuteType() {
		return lawCauseInterfaceService.statCauseExcuteType();
	}

	/**
	 * 执法领域
	 *
	 * @return
	 */
	@GetMapping("lawdomain")
	public List<Map<String, Object>> getLawDomain() {
		return lawCauseInterfaceService.getLawDomain();
	}

	/**
	 * 法律法规分组
	 *
	 * @return
	 */
	@GetMapping("lawcodegroup")
	public List<Map<String, Object>> getLawCodeGroup() {
		return lawCauseInterfaceService.getLawCodeGroup();
	}

	/**
	 * 获取处罚事项
	 *
	 * @return
	 */
	@RequestMapping("listExceuteTypeByCauseCode")
	public List<TcLawRelCauseExcuteType> listExceuteTypeByCauseCode(@RequestBody List<String> causeCodes) {
		return lawCauseInterfaceService.listExceuteTypeByCauseCode(causeCodes);
	}

	/**
	 * 自由裁量
	 * 
	 * @param causeCodes
	 * @return
	 */
	@RequestMapping("listClDetailByCauseCode")
	public List<TcLawClDetail> listClDetailByCauseCode(@RequestBody List<String> causeCodes) {
		return lawCauseInterfaceService.listClDetailByCauseCode(causeCodes);
	}
	
	/**
	 * 法规名称补全
	 */
	@RequestMapping("searchlaw")
	public List<TcDicLaw> searchLaw(String title, int type){
		return lawCauseInterfaceService.searchLaw(title, type);
	}
	
	/**
	 * 查询包含违责活罚则的条目
	 * @param lawId
	 * @return
	 */
	@RequestMapping("searchlawitem")
	public List<TcDicLawItem> searchLawItem(long lawId, int type){
		return lawCauseInterfaceService.searchLawItem(lawId, type);
	}

	/**
	 * code查询id
	 * @param causeCodes
	 * @return
	 */
	@RequestMapping("listCasueIDByCauseCode")
	public List<LawCauseItem> listCasueIDByCauseCode(@RequestBody List<String> causeCodes){
		return lawCauseInterfaceService.listCasueIDByCauseCode(causeCodes);
	}
}
